<?php
//--------------------------------------------------
//	Filename: profile_show.php
//--------------------------------------------------
// Information:
// This file shows a single blog-post. 
// functions_blog.php is included through this file.
//--------------------------------------------------
if( !defined('IN_INDEX') )
{
	printError("ACCESS DENIED", "This page is hidden.");
	exit;
}
if(!checkSession())
{
			function redirect($url)
			{
			?>
				<script type="text/javascript">
					{
					window.location = "<?=$url?>";
					}
				</script>
			<?php 
			}
			redirect("index.php?action=login");
	exit;
}

if(!isset($BLOG))
{
	include('inc/functions_blog.php');
	include('inc/functions_gym.php');
	include('inc/functions_award.php');
	
	$BLOG = array();
	if(isset($_REQUEST['tid']))
	{
		$BLOG = getTrainingById($_REQUEST['tid']);
	}
	else
	{
		header('Location: index.php?action=profile');
		exit;
	}
}

if(!isset($_REQUEST['commentid']))
	{

	}
	else
	{
	$sql="DELETE FROM comments WHERE comment_id = " . $_REQUEST['commentid'] .  "";
	if(!$result = $db->sql_query($sql)) 
			{
					printError("SQL ERROR", mysql_error());
			}
	// Add -1 to user_posts
			$sql2 = "UPDATE users SET user_posts = user_posts-1 WHERE user_id =" . $_REQUEST['userid'] . "";
			if(!$result2 = $db->sql_query($sql2))
			{
				printError("SQL ERROR", mysql_error());
			}
		$id = $_REQUEST['tid'];
		echo"<meta http-equiv=\"refresh\" content=\"0;url=index.php?action=profile&amp;sub=show&tid=$id\" />";
	}

$dateformat = $CONFIG['date_format'];
$dateformat_long = $CONFIG['date_format_long'];

$newer_training = getNewerTrainingId($BLOG['user_id'], $_REQUEST['tid'], $BLOG['date']);
$older_training = getPreviouesTrainingId($BLOG['user_id'], $_REQUEST['tid'], $BLOG['date']);

if(checkSession() && ($USER->getId() == $BLOG['user_id']))
{
	$U_PROFILE = $USER;
	$url_to_post = "index.php?action=profile&amp;sub=show&amp;tid=" . $BLOG['id'];
}
else
{
	$U_PROFILE = new User('id', $BLOG['user_id']);
	$url_to_post = "index.php?action=profile&amp;sub=show&amp;id=" . $U_PROFILE->getId() . "&amp;tid=" . $BLOG['id'];
}

$comments = getBlogCommentsSort(" WHERE post_type='training' AND post_id='" . $BLOG['id'] . "' ",$USER->getSortComments());
$comments_text0 = str_replace('VAR1', count($comments), $LANG['post_comments0']);
$comments_text1 = str_replace('VAR1', count($comments), $LANG['post_comments1']);
$comments_text2 = str_replace('VAR1', count($comments), $LANG['post_comments2']);

$comments_per_page = 15;
$start = 0;

if(checkSession())
		{
			$comments_per_page = $USER->getCommentsPerPage();
		}
		if(isset($_REQUEST['p']))
		{
			$start = ($_REQUEST['p'] * $comments_per_page) - $comments_per_page;
		}
		
		$end = $start + $comments_per_page;
		if($end > count($comments))
		{
			$end = count($comments);
		}
		
// Counter
$ip = $_SERVER['REMOTE_ADDR']; 
$category = "post";
$page = $_REQUEST['tid']; 
$timenow = mktime();

//Check that the IP is not already listed for the current page 
$viewer_check_query = "SELECT ip, category, page, time FROM counter WHERE ip = '$ip' AND category = '$category' AND page = '$page'"; 
$viewer_check_result = mysql_query($viewer_check_query); 
$viewer_check_numrows = mysql_num_rows($viewer_check_result); 
while($row = mysql_fetch_assoc($viewer_check_result)) {
    $time = $row['time'];
}
    //If numrows is equal to zero, then the user is new 
    if($viewer_check_numrows == 0){ 
        //Add the new entry 
        $viewer_new_query = "INSERT INTO counter (ip, category, page, time) VALUES 
        ('$ip', '$category', '$page', '$timenow')"; 
        $viewer_new_result = mysql_query($viewer_new_query); 
    } 
	//Timeout of 1 hours before same ip can add one new hit
	elseif((time() - $time) > 3600 ){ 
        //Add the new entry 
        $viewer_new_query = "INSERT INTO counter (ip, category, page, time) VALUES 
        ('$ip', '$category', '$page', '$timenow')"; 
        $viewer_new_result = mysql_query($viewer_new_query); 
    } 

//Get the total number of views for this page 
$viewer_total_query = "SELECT * FROM counter WHERE category = '$category' AND page = '$page'"; 
$viewer_total_result = mysql_query($viewer_total_query); 
$viewer_total_numrows = mysql_num_rows($viewer_total_result); 

?>
<!--
<script src="./jscript/prettyphoto/js/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8"></script>
-->
<link rel="stylesheet" href="./jscript/prettyphoto/css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
<script src="./jscript/prettyphoto/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
function quote_comment(textarea_id, comment_id)
{
	var element = document.getElementById(textarea_id);
	var name = document.getElementById('name_' + comment_id);
	var date = document.getElementById('date_' + comment_id);
	var comment = document.getElementById('comment_' + comment_id);
	element.value += '[quote name=' + name.innerHTML.trim() + ' date=' + date.value + ']' + comment.innerHTML.trim() + '[/quote]';
}

function delete_comment(id, number, userid)
{
	var confirmation = confirm('<?php echo translate("confirm_delete_comment"); ?>');
	if(confirmation == true)
	{
		window.location = window.location + "&delete&commentid=" + id + "&userid=" +  userid;
	}
}

function show_stat(id)
{
	var el = document.getElementById('ex_stats_' + id);
	var b = document.getElementById('ex_stats_button_' + id);
	
	if(el.style.display == "block")
	{
		el.style.display="none";
		b.innerHTML = "<?php echo translate('show_stats'); ?>";
	}
	else
	{
			el.style.display="block";
			b.innerHTML = "<?php echo translate('hide_stats'); ?>";
	}
}
</script>

<?php
    	$view_blog = true;
		if($U_PROFILE->getBlogPrivacy() == 1 && $USER->getId() != $U_PROFILE->getId())
		{
				echo translate('thisbloghasrestrictedview');
				$view_blog = false;	
		}
		
		if($U_PROFILE->getBlogPrivacy() == 2 && $USER->getId() != $U_PROFILE->getId() && checkFriendAccepted($U_PROFILE->getId(), $USER->getId()) != "accepted")
		{
				echo translate('thisbloghasrestrictedview_friends');
				$view_blog = false;
		}
		
		if($view_blog)
		{ // restrict view START
			?>

<!-- Show single blog post START-->
<?php
if(isset($_REQUEST['tid']))
{
	if(isset($_POST['toggle_commenting']) && (checkSession() && ($USER->getId() == $BLOG['user_id'])) )
	{
		if($BLOG['disable_comment'] == 1)
		{
			$sql = "UPDATE " . TRAINING_TABLE . " SET disable_comment='0' WHERE training_id='" . $BLOG['id'] . "'";
		}
		else
		{
			$sql = "UPDATE " . TRAINING_TABLE . " SET disable_comment='1' WHERE training_id='" . $BLOG['id'] . "'";
		}
		
		if(!$result = $db->sql_query($sql))
		{
			postError('SQL_ERROR', mysql_error());
		}
		else
		{
			$BLOG = getTrainingById($_REQUEST['tid']);
		}
	}
	
	$blog_user_id = $U_PROFILE->getId();
?>

<div id='postpath'>
		<a title="<?php echo translate('gotofrontpage'); ?>" href="index.php"><?php echo translate('home'); ?></a>
		 &gt; <a href="index.php?action=blogs" title='<?php echo translate('showallblogs'); ?>'><?php echo translate('blog'); ?></a> &gt; 
         <a href="index.php?action=profile&amp;id=<?php echo $U_PROFILE->getId(); ?>"><?php echo $U_PROFILE->getFirstname() . " " . ucf($U_PROFILE->getLastname()); ?></a>
         &gt; <a href="<?php echo $url_to_post; ?>"><?php echo $BLOG['title']; ?></a>
</div>

<div id="like_popup_view" style="display:none;"></div>

<div class="post">
	<h2><a class="title" href="<?php echo $url_to_post; ?>"><?php echo $BLOG['title']; ?></a></h2>
	<div class="info">
    
		<span class="date"><?php echo formatDate($BLOG['date'], $dateformat); ?></span>
        <?php 
		if($BLOG['date_update'] != 0)
		{
		?>
        <span class="date"><?php echo ucf(translate('updated')) . " " . translate('for2') . " " . getHowLongAgo($BLOG['date_update']); ?></span>
        <?php
		}
		?>
        
		<span class="author"><a href="index.php?action=profile&amp;id=<?php echo $U_PROFILE->getId(); ?>" title="<?php echo translate('postby'); ?> <?php echo $U_PROFILE->getFirstname() . " " . ucf($U_PROFILE->getLastname()); ?>"><?php echo $U_PROFILE->getFirstname() . " " . ucf($U_PROFILE->getLastname()); ?></a> <?php if($BLOG['meet'] == 2) { echo " " . $viewer_total_numrows . " "; if($viewer_total_numrows == 1) { echo translate('oneview'); } else { echo translate('views'); }} ?></span>
	&nbsp;&nbsp;&nbsp;	
		<a href="javascript:void(0);" onclick="open_who_likes(<?php echo $_REQUEST['tid'];?>);"><img src="./img/thumb_up.png" alt="<?php echo translate('like');?>" /></a><span class="like" rel="<?php echo $_REQUEST['tid'];?>"> <?php echo count_numberOfPersons_like($U_PROFILE->getId(), $_REQUEST['tid']);?>
		<?php if(is_like($U_PROFILE->getId(),$_SESSION['user_id'], $_REQUEST['tid'])):?>
			<a href="javascript:void(0);" onclick="like_unlike('unlike',<?php echo $_SESSION['user_id'];?>,<?php echo $U_PROFILE->getId();?>,<?php echo $_REQUEST['tid'];?>);" ><?php echo translate('unlike');?></a>
		<?php else:?>
			<a href="javascript:void(0);" onclick="like_unlike('like',<?php echo $_SESSION['user_id'];?>,<?php echo $U_PROFILE->getId();?>,<?php echo $_REQUEST['tid'];?>);" ><?php echo translate('like');?></a>
		<?php endif;?>
		</span>
	&nbsp;&nbsp;
		<?php echo ui_aj_follow_this_user($user_id=$U_PROFILE->getId(), $div_id=$_REQUEST['tid']);?>
<!-- Only for admins and blog owner-->    
<?php
if(isset($USER) && $USER->getId() == $U_PROFILE->getId() or $USER->getRank() >= 5)
{
	?>
		
      <span class="editpost"><a href="index.php?action=profile&amp;id=<?php echo $U_PROFILE->getId(); ?>&amp;sub=editt&amp;tid=<?php echo $BLOG['id']; ?>" title="<?php echo translate('editp_sub'); ?>"><?php echo translate('editp'); ?></a></span>
	<?php
}
?>       
		
		<span class="comments"><a href="#comments" title="<?php echo translate('gotocomments'); ?>"><?php echo translate('gotocomments'); ?></a></span>
<div class="fixed"></div>
		<div class="content">
<?php
// Check if text only
if($BLOG['meet'] != 2)
{
	
if(count($BLOG['lifts']) > 0)
{
	?>
	<table class="exercises_table" border="0" colspan="0" rowspan="0"  style="float:left;">
		<tr>
			<td width="492">
	<?php
}

$total_lifted = 0;

$total_set = 0;
$total_reps = 0;

$total2_set = 0;
$total2_reps = 0;

$prev_ex = 0;

$col_counter = 0;
$counter = 0;
$summary_weight = 0;
$temp_list = array();
foreach($BLOG['lifts'] as $k => $v)
{
	if($v['exercise_id'] != $prev_ex)
	{
		if($counter > 0)
		{
			if($col_counter >= 2)
			{
				$col_counter = 0;
				echo "
					
						<a href=\"javascript:void(0);\" title=\"Show/hide stats\" onclick=\"show_stat('" . $counter . "'); return false;\"><span id=\"ex_stats_button_" . $counter . "\">" . translate('show_stats') . "</span></a>\n
						<div class=\"ex_stats\" id=\"ex_stats_" . $counter . "\">
		" . translate('lifted') . " <b>" . $summary_weight . "" . $w_metric . "</b> " . translate('totally') . " ". strtolower(translate('on')) ." <b>" . $total_set . "</b> ". strtolower(translate('set')) ." ". strtolower(translate('and')) ." <b>". $total_reps ."</b> ". strtolower(translate('reps')) .". <br />" . ucf(translate('averageprliftwas')) . " <b>" . $average_lift . "" . $w_metric . ".</b><br />\n";
						echo post_stat_image($temp_list);
						echo"
						</div>
					</td>
				</tr>
				<tr>
					<td width=\"210\">\n";
					$total_set = 0;
					$total_reps = 0;
					$summary_weight = 0;
					$temp_list = array();
			}
			else
			{
				echo "
					
					<a href=\"javascript:void(0);\" title=\"Show/hide stats\" onclick=\"show_stat('" . $counter . "'); return false;\"><span id=\"ex_stats_button_" . $counter . "\">" . translate('show_stats') . "</span></a>\n
					<div class=\"ex_stats\" id=\"ex_stats_" . $counter . "\">
						" . translate('lifted') . " <b>" . $summary_weight . "" . $w_metric . "</b> " . translate('totally') . " ". strtolower(translate('on')) ." <b>" . $total_set . "</b> ". strtolower(translate('set')) ." ". strtolower(translate('and')) ." <b>". $total_reps ."</b> ". strtolower(translate('reps')) .". <br />" . ucf(translate('averageprliftwas')) . " <b>" . $average_lift . "" . $w_metric . ".</b><br />\n";
						echo post_stat_image($temp_list);
						echo"
						</div>
				</td>
				<tr></tr>
				<td width=\"370\">\n";
				$total_set = 0;
				$total_reps = 0;
				$summary_weight = 0;
				$temp_list = array();
			}
		}
		$col_counter++;
		$counter++;
		$prev_ex = $v['exercise_id']; 
		echo "<b>" . ucf(translate(getExercisename($prev_ex))) . "</b><br />\n";
		// Get personal bests
		// 1 RM
		$currentpr = checkIfNewPr($v['kg'], 1, $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
		$currentpr_tid = checkIfNewPrTid($v['kg'], 1, $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
		// 2 RM
		$currentpr2 = checkIfNewPr($v['kg'], 2, $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
		$currentpr2_tid = checkIfNewPrTid($v['kg'], 2, $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
		// 3 RM
		$currentpr3 = checkIfNewPr($v['kg'], 3, $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
		$currentpr3_tid = checkIfNewPrTid($v['kg'], 3, $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
		
		// Show personal best on selected exercise
		if($USER->getShowPb() == 1)
		{
			if($currentpr != 0 || $currentpr2 != 0 || $currentpr3 != 0)
			{
				// Training
				if($BLOG['meet'] == 0)
				{
					// KG selected
					if($w_metric == "kg")
					{
						echo "<span style='font-size: x-small; color: grey;'>(";
						if($currentpr != 0)
						{ 
							echo "<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr_tid . "'>1 RM = " . r_nr2(calcFromKg($currentpr)) . "" . $w_metric . "</a>";
						}
						if($currentpr != 0 && $currentpr2 != 0)
						{
							echo ", ";
						} 
						if($currentpr2 != 0)
						{
							 echo "<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr2_tid . "'>2 RM = " .  r_nr2(calcFromKg($currentpr2)) . "" . $w_metric . "</a>";
						}
						if($currentpr != 0 || $currentpr2 != 0 && $currentpr3 != 0)
						{
							echo ", ";
						} 
						if($currentpr3 != 0)
						{
							echo "<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr3_tid . "'>3 RM = " .  r_nr2(calcFromKg($currentpr3)) . "" . $w_metric . "</a>";
						}
						echo ")<br /></span>";
					}
					// LBS selected
					else
					{
						echo "<span style='font-size: x-small; color: grey;'>(";
						if($currentpr != 0)
						{ 
							echo "<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr_tid . "'>1 RM = " . r_nr(calcFromKg($currentpr)) . "" . $w_metric . "</a>";
						}
						if($currentpr != 0 && $currentpr2 != 0)
						{
							echo ", ";
						} 
						if($currentpr2 != 0)
						{
							 echo "<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr2_tid . "'>2 RM = " .  r_nr(calcFromKg($currentpr2)) . "" . $w_metric . "</a>";
						}
						if($currentpr != 0 || $currentpr2 != 0 && $currentpr3 != 0)
						{
							echo ", ";
						} 
						if($currentpr3 != 0)
						{
							echo "<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr3_tid . "'>3 RM = " .  r_nr(calcFromKg($currentpr3)) . "" . $w_metric . "</a>";
						}
						echo ")<br /></span>";
					}
				}
				// Meet
				elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
				{
					if($w_metric == "kg")
					{
						echo "<span style='font-size: x-small; color: grey;'>
						(<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr_tid . "'>1 RM = " .  r_nr2(calcFromKg($currentpr)) . "" . $w_metric . "</a>)
						<br /></span>";
					}
					else
					{
						echo "<span style='font-size: x-small; color: grey;'>
						(<a style='font-size: x-small; color: grey;' href='index.php?action=profile&sub=show&tid=" . $currentpr_tid . "'>1 RM = " .  r_nr(calcFromKg($currentpr)) . "" . $w_metric . "</a>)
						<br /></span>";
					}
				}
			}
		}
	
	}
	
	//If kg is selected
	if($w_metric == "kg")
	{
		if($USER->getSortKgReps() == 1)
		{
			// If marked as training
			if($BLOG['meet'] == 0)
			{
				// If a lift fail
				if($v['kg'] > 0 && $v['reps'] == 0)
				{
					if($USER->getShowWeightchange() == 1)
					{
						// Display set with red color
						echo "<span style='color: red;'><div style='float: left; clear: right;'><img src='img/bomb.png' alt='bomb' /></div>" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "</span> <span style='color: red;'>x</span> <span style='color: red;'>" . $v['reps'] . " </span> ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					}
					else
					{
						// Display set with red color
						echo "<span style='color: red;'>" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "</span> <span style='color: red;'>x</span> <span style='color: red;'>" . $v['reps'] . "</span> ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					}
				}
				elseif($v['reps'] >= 1)
				{
					// Check if the user wants to show weightchanges
					if($USER->getShowWeightchange() == 1)
					{
						// Find the first set
						$check_first_set = checkIfWeightChangeOnSetsIsFirstSet($_REQUEST['tid'],$v['exercise_id']);
						
						if($check_first_set != $v['id'])
						{
								// Lifted at previous set
								$prev_weight = checkWeightChangeOnSets($_REQUEST['tid'],$v['id'],$v['exercise_id']);
								
								// Difference from the previous set
								$diff_prev = r_nr2(calcFromKg($v['kg']))-r_nr2(calcFromKg($prev_weight));
								
								// Display increase or deacrease
								if($diff_prev == 0)
								{
									// Same weight
									echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_blue.png' alt='same' /></div></span> ";
								}
								elseif($diff_prev > 0)
								{
									// Increase
									echo "<span style='color: green; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_up_green.png' alt='increase' /></div>+" . $diff_prev . $w_metric ."</span> ";
								}
								elseif($diff_prev < 0)
								{
									// Deacrease
									echo "<span style='color: red; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_down_red.png' alt='decrease' /></div>" . substr_replace($diff_prev,"", 0,0) . $w_metric ."</span> "; 
								}
						}
						else
						{
							// First set
							echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_green.png' alt='first' /></div></span> ";
						}
					}
					
					// Display set with null kg only repetitions
					if($v['kg'] == 0 && $v['type'] == "")
					{
						echo $v['reps'] . " "; 
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition');
							
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							} 
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
						}
					}
					// Display normal set
					elseif($v['type'] == "")
					{
						echo "" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'] . "";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
					}
					// Display dropset
					elseif($v['type'] == "dropset")
					{
						$checkset  = checkPreviouesSet($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset2 = checkPreviouesSet2($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset3 = checkPreviouesSet3($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset4 = checkPreviouesSet4($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset5 = checkPreviouesSet5($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
															
						if($checkset == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset2 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset3 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset4 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset5 == "dropset")

						{
							echo "<span style='padding-left:8px'></span>";
						}
						
						echo "" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'];
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('dropset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i>";
					}
					// Display superset with 0 kg
					elseif($v['type'] == "superset" && $v['kg'] == 0)
					{
					echo $v['reps'] . " "; 
					
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> "; 
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
						}
					}
					// Display normal superset
					elseif($v['type'] == "superset")
					{
						echo "" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'];
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
					}
				}
			}
			// If marked as meet
			elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
			{
				if($v['reps'] == 1)
				{
					echo r_nr2(calcFromKg($v['kg'])) . "" . $w_metric;
				}
				elseif($v['reps'] == 0)
				{
					echo "<span style='text-decoration: line-through;'>" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "</span>";
				}
				elseif($v['reps'] > 1)
				{
					echo r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'];
				}
			}
		}
		else
		{
			// If marked as training
			if($BLOG['meet'] == 0)
			{
				// If a lift fail
				if($v['kg'] > 0 && $v['reps'] == 0)
				{
					if($USER->getShowWeightchange() == 1)
					{
						// Display set with red color
					echo "<span style='color: red;'><div style='float: left; clear: right;'><img src='img/bomb.png' alt='bomb' /></div>" . $v['reps'] . " x " . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "</span> ";
					
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					
					}
					else
					{
						// Display set with red color
						echo "<span style='color: red;'>" . $v['reps'] . " x " . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "</span> ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					}
				}
				elseif($v['reps'] >= 1)
				{
					// Check if the user wants to show weightchanges
					if($USER->getShowWeightchange() == 1)
					{
						// Find the first set
						$check_first_set = checkIfWeightChangeOnSetsIsFirstSet($_REQUEST['tid'],$v['exercise_id']);
						
						if($check_first_set != $v['id'])
						{
								// Lifted at previous set
								$prev_weight = checkWeightChangeOnSets($_REQUEST['tid'],$v['id'],$v['exercise_id']);
								
								// Difference from the previous set
								$diff_prev = r_nr2(calcFromKg($v['kg']))-r_nr2(calcFromKg($prev_weight));
								
								// Display increase or deacrease
								if($diff_prev == 0)
								{
									// Same weight
									echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_blue.png' alt='same' /></div></span> ";
								}
								elseif($diff_prev > 0)
								{
									// Increase
									echo "<span style='color: green; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_up_green.png' alt='increase' /></div>+" . $diff_prev . $w_metric ."</span> ";
								}
								elseif($diff_prev < 0)
								{
									// Deacrease
									echo "<span style='color: red; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_down_red.png' alt='decrease' /></div>" . substr_replace($diff_prev,"", 0,0) . $w_metric ."</span> "; 
								}
						}
						else
						{
							// First set
							echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_green.png' alt='first' /></div></span> ";
						}
					}
					// Display set with null kg only repetitions
					if($v['kg'] == 0 && $v['type'] == "")
					{
						echo $v['reps'] . " "; 
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition'); 
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
						}
					}
					// Display normal set
					if($v['type'] == "")
					{
						echo "" . $v['reps'] . " x " . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
					}
					// Display dropset
					elseif($v['type'] == "dropset")
					{
						$checkset = checkPreviouesSet($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset2 = checkPreviouesSet2($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset3 = checkPreviouesSet3($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset4 = checkPreviouesSet4($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset5 = checkPreviouesSet5($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
												
						if($checkset == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset2 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset3 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset4 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset5 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						
						echo "" . $v['reps'] . " x " . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric;
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo" <i>(" . translate('dropset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i>";
					}
					// Display superset with 0 kg
					elseif($v['type'] == "superset" && $v['kg'] == 0)
					{
					echo $v['reps'] . " "; 
					
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> "; 
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
						}
					}
					// Display normal superset
					elseif($v['type'] == "superset")
					{
						echo "" . $v['reps'] . " x " . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric;
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
					}
				}
			}
			elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
			{
				if($v['reps'] == 1)
				{
					echo r_nr2(calcFromKg($v['kg'])) . "" . $w_metric;
				}
				elseif($v['reps'] == 0)
				{
					echo "<span style='text-decoration: line-through;'>" . r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . "</span>";
				}
				elseif($v['reps'] > 1)
				{
					echo $v['reps'] . " x " .  r_nr2(calcFromKg($v['kg'])) . "" . $w_metric . " ";
				}
			}
		}
		
		// Get video if included
		if($v['url'] != "")
		{
		echo " <a href='" . $v['url'] . "' rel='prettyPhoto'><img alt='". translate('show_video') ."' title='". translate('show_video') ."' src='img/video.png' /></a>";
		}
		
		//Check if its a new pr
			if($v['reps'] >= 1)
			{
				
			$currentpr = checkIfNewPr($v['kg'], $v['reps'], $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
			$currentprtid = checkIfNewPrTid($v['kg'], $v['reps'], $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
			$datecurrentpr = checkIfNewPrDate($v['kg'], $v['reps'], $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
				
				// Check if training or meet and if any lift is found
				if($currentpr != 0 && $currentpr == $v['kg'])
				{
					if($BLOG['meet'] == 0)
					{
						echo " <img alt='". translate('tiepr') ."' title='". translate('tiepr') ."' src='img/star_silver.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b> " . translate('similarpersrecord') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
					elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
					{
						echo " <img alt='". translate('tiepr') ."' title='". translate('tiepr') ."' src='img/star_silver.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b> " . translate('similarpersrecordmeet') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
				}
				elseif($currentpr != 0 && $currentpr < $v['kg'])
				{
					$diffkg = $v['kg']-$currentpr;
					if($BLOG['meet'] == 0)
					{
						echo " <img alt='". translate('newpr') ."' title='". translate('newpr') ."' src='img/star.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b>" . $diffkg . $w_metric . " " . translate('newpersrecord') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
					elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
					{
						echo " <img alt='". translate('newpr') ."' title='". translate('newpr') ."' src='img/star.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b>" . $diffkg . $w_metric . " " . translate('newpersrecordmeet') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
				}
			}
		//echo "<br />\n";
		getAwardForTraining($_REQUEST['tid'], $v['exercise_id'], $v['id']);
		echo "<br />";
		//echo "Tuandt test".$v['id']."<br/>\n";
	}
	// If LBS i selected
	else
	{
		if($USER->getSortKgReps() == 1)
		{
			// If marked as training
			if($BLOG['meet'] == 0)
			{
				// If a lift fail
				if($v['kg'] > 0 && $v['reps'] == 0)
				{
					if($USER->getShowWeightchange() == 1)
					{
						// Display set with red color
						echo "<span style='color: red;'><div style='float: left; clear: right;'><img src='img/bomb.png' alt='bomb' /></div>" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "</span> <span style='color: red;'>x</span> <span style='color: red;'>" . $v['reps'] . " </span> ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					}
					else
					{
						// Display set with red color
						echo "<span style='color: red;'>" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "</span> <span style='color: red;'>x</span> <span style='color: red;'>" . $v['reps'] . "</span> ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					}
				}
				elseif($v['reps'] >= 1)
				{
					// Check if the user wants to show weightchanges
					if($USER->getShowWeightchange() == 1)
					{
						// Find the first set
						$check_first_set = checkIfWeightChangeOnSetsIsFirstSet($_REQUEST['tid'],$v['exercise_id']);
						
						if($check_first_set != $v['id'])
						{
								// Lifted at previous set
								$prev_weight = checkWeightChangeOnSets($_REQUEST['tid'],$v['id'],$v['exercise_id']);
								
								// Difference from the previous set
								$diff_prev = r_nr(calcFromKg($v['kg']))-r_nr(calcFromKg($prev_weight));
								
								// Display increase or deacrease
								if($diff_prev == 0)
								{
									// Same weight
									echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_blue.png' alt='same' /></div></span> ";
								}
								elseif($diff_prev > 0)
								{
									// Increase
									echo "<span style='color: green; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_up_green.png' alt='increase' /></div>+" . $diff_prev . $w_metric ."</span> ";
								}
								elseif($diff_prev < 0)
								{
									// Deacrease
									echo "<span style='color: red; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_down_red.png' alt='decrease' /></div>" . substr_replace($diff_prev,"", 0,0) . $w_metric ."</span> "; 
								}
						}
						else
						{
							// First set
							echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_green.png' alt='first' /></div></span> ";
						}
					}
					
					// Display set with null kg only repetitions
					if($v['kg'] == 0 && $v['type'] == "")
					{
						echo $v['reps'] . " "; 
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition'); 
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
						}
					}
					// Display normal set
					if($v['type'] == "")
					{
						echo "" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'] . " ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
					}
					// Display dropset
					elseif($v['type'] == "dropset")
					{
						$checkset = checkPreviouesSet($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset2 = checkPreviouesSet2($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset3 = checkPreviouesSet3($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset4 = checkPreviouesSet4($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset5 = checkPreviouesSet5($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
												
						if($checkset == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset2 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset3 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset4 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset5 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						
						echo "" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'];
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('dropset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i>";
					}
					// Display superset with 0 kg
					elseif($v['type'] == "superset" && $v['kg'] == 0)
					{
					echo $v['reps'] . " "; 
					
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> "; 
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
						}
					}
					// Display normal superset
					elseif($v['type'] == "superset")
					{
						echo "" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'];
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
					}
				}
			}
			// If marked as meet
			elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
			{
				if($v['reps'] == 1)
				{
					echo r_nr(calcFromKg($v['kg'])) . "" . $w_metric;
				}
				elseif($v['reps'] == 0)
				{
					echo "<span style='text-decoration: line-through;'>" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "</span>";
				}
				elseif($v['reps'] > 1)
				{
					echo r_nr(calcFromKg($v['kg'])) . "" . $w_metric . " x " . $v['reps'];
				}
			}
		}
		else
		{
			// If marked as training
			if($BLOG['meet'] == 0)
			{
				// If a lift fail
				if($v['kg'] > 0 && $v['reps'] == 0)
				{
					if($USER->getShowWeightchange() == 1)
					{
						// Display set with red color
					echo "<span style='color: red;'><div style='float: left; clear: right;'><img src='img/bomb.png' alt='bomb' /></div>" . $v['reps'] . " x " . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "</span> ";
					
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					
					}
					else
					{
						// Display set with red color
						echo "<span style='color: red;'>" . $v['reps'] . " x " . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "</span> ";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo "<span style='color: red;'> @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: red;' rel='prettyPhoto'>RPE</a></span> ";
						}
					}
				}
				elseif($v['reps'] >= 1)
				{
					// Check if the user wants to show weightchanges
					if($USER->getShowWeightchange() == 1)
					{
						// Find the first set
						$check_first_set = checkIfWeightChangeOnSetsIsFirstSet($_REQUEST['tid'],$v['exercise_id']);
						
						if($check_first_set != $v['id'])
						{
								// Lifted at previous set

								$prev_weight = checkWeightChangeOnSets($_REQUEST['tid'],$v['id'],$v['exercise_id']);
								
								// Difference from the previous set
								$diff_prev = r_nr(calcFromKg($v['kg']))-r_nr(calcFromKg($prev_weight));
								
								// Display increase or deacrease
								if($diff_prev == 0)
								{
									// Same weight
									echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_blue.png' alt='same' /></div></span> ";
								}
								elseif($diff_prev > 0)
								{
									// Increase
									echo "<span style='color: green; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_up_green.png' alt='increase' /></div>+" . $diff_prev . $w_metric ."</span> ";
								}
								elseif($diff_prev < 0)
								{
									// Deacrease
									echo "<span style='color: red; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_down_red.png' alt='decrease' /></div>" . substr_replace($diff_prev,"", 0,0) . $w_metric ."</span> "; 
								}
						}
						else
						{
							// First set
							echo "<span style='color: lightblue; font-size: 0.8em;'><div style='float: left; clear: right;'><img src='img/arrow_right_green.png' alt='first' /></div></span> ";
						}
					}
					
					// Display set with null kg only repetitions
					if($v['kg'] == 0 && $v['type'] == "")
					{
						echo $v['reps'] . " "; 
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition');
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							} 
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
						}
					}
					// Display normal set
					if($v['type'] == "")
					{
						echo "" . $v['reps'] . " x " . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "";
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
					}
					// Display dropset
					elseif($v['type'] == "dropset")
					{
						$checkset = checkPreviouesSet($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset2 = checkPreviouesSet2($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset3 = checkPreviouesSet3($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset4 = checkPreviouesSet4($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
						$checkset5 = checkPreviouesSet5($_REQUEST['tid'], $v['id'], $v['type_nr'], $v['exercise_id']);
												
						if($checkset == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset2 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset3 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset4 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						if($checkset5 == "dropset")
						{
							echo "<span style='padding-left:8px'></span>";
						}
						
						echo "" . $v['reps'] . " x " . r_nr(calcFromKg($v['kg'])) . "" . $w_metric;
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('dropset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i>";
					}
					// Display superset with 0 kg
					elseif($v['type'] == "superset" && $v['kg'] == 0)
					{
					echo $v['reps'] . " "; 
					
						if($v['reps'] == 1) 
						{ 
							echo translate('repetition');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> "; 
						}
						elseif($v['reps'] > 1)
						{
							echo translate('repetitions');
							
							// Display RPE
							if($v['rpe'] > 0)
							{
								echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
							}
							
							echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
						}
					}
					// Display normal superset
					elseif($v['type'] == "superset")
					{
						echo "" . $v['reps'] . " x " . r_nr(calcFromKg($v['kg'])) . "" . $w_metric;
						
						// Display RPE
						if($v['rpe'] > 0)
						{
							echo " @ " . $v['rpe'] . " <a href='./img/rpe.JPG' target='_blank'style='color: #555555;' rel='prettyPhoto'>RPE</a> ";
						}
						
						echo " <i>(" . translate('superset') . ""; if($v['type_nr'] != 0) { echo " " . $v['type_nr']; } echo ")</i> ";
					}
				}
			}
			elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
			{
				if($v['reps'] == 1)
				{
					echo r_nr(calcFromKg($v['kg'])) . "" . $w_metric;
				}
				elseif($v['reps'] == 0)
				{
					echo "<span style='text-decoration: line-through;'>" . r_nr(calcFromKg($v['kg'])) . "" . $w_metric . "</span>";
				}
				elseif($v['reps'] > 1)
				{
					echo $v['reps'] . " x " .  r_nr(calcFromKg($v['kg'])) . "" . $w_metric . " ";
				}
			}
		}
		
		// Get video if included
		if($v['url'] != "")
		{
		echo " <a href='" . $v['url'] . "' rel='prettyPhoto'><img alt='". translate('show_video') ."' title='". translate('show_video') ."' src='img/video.png' /></a>";
		}
		
		//Check if its a new pr
			if($v['reps'] >= 1)
			{
				
			$currentpr = checkIfNewPr($v['kg'], $v['reps'], $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
			$currentprtid = checkIfNewPrTid($v['kg'], $v['reps'], $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
			$datecurrentpr = checkIfNewPrDate($v['kg'], $v['reps'], $v['exercise_id'], $BLOG['date'], $U_PROFILE->getId(), $BLOG['meet']);
				
				// Check if training or meet and if any lift is found
				if($currentpr != 0 && $currentpr == $v['kg'])
				{
					if($BLOG['meet'] == 0)
					{
						echo " <img alt='". translate('tiepr') ."' title='". translate('tiepr') ."' src='img/star_silver.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b> " . translate('similarpersrecord') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
					elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
					{
						echo " <img alt='". translate('tiepr') ."' title='". translate('tiepr') ."' src='img/star_silver.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b> " . translate('similarpersrecordmeet') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
				}
				elseif($currentpr != 0 && $currentpr < $v['kg'])
				{
					$diffkg = $v['kg']-$currentpr;
					if($BLOG['meet'] == 0)
					{
						echo " <img alt='". translate('newpr') ."' title='". translate('newpr') ."' src='img/star.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b>" . r_nr(calcFromKg($diffkg)) . $w_metric . " " . translate('newpersrecord') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
					elseif($BLOG['meet'] == 1 || $BLOG['meet'] == 3)
					{
						echo " <img alt='". translate('newpr') ."' title='". translate('newpr') ."' src='img/star.png' /><font size='1' style='color:darkgreen;'><a style='color:darkgreen;' href='index.php?action=profile&sub=show&tid=$currentprtid'><b>" . r_nr(calcFromKg($diffkg)) . $w_metric . " " . translate('newpersrecordmeet') . " " . formatDate($datecurrentpr, $dateformat) . "!</b></a></font>";
					}
				}
			}
		echo "<br />\n";
	}
	$temp_list[] = $v['kg'];
	$summary_weight += r_nr(calcFromKg($v['kg'])) * $v['reps'];
	$total_lifted += r_nr(calcFromKg($v['kg'])) * $v['reps'];
	$total_set += 1;
	$total_reps +=$v['reps'];
	$total2_set += 1;
	$total2_reps +=$v['reps'];
	if($total_reps != 0)
	{
	$average_lift = round($summary_weight/$total_reps,2);
	}
	if($total2_reps != 0)
	{
	$average_lift2 = round($total_lifted/$total2_reps,2);
	}
	
}

echo "
					
	<a href=\"javascript:void(0);\" title=\"Show/hide stats\" onclick=\"show_stat('" . $counter . "'); return false;\"><span id=\"ex_stats_button_" . $counter . "\">" . translate('show_stats') . "</span></a>\n
					<div class=\"ex_stats\" id=\"ex_stats_" . $counter . "\">
						" . translate('lifted') . " <b>" . $summary_weight . "" . $w_metric . "</b> " . translate('totally') . " ". strtolower(translate('on')) ." <b>" . $total_set . "</b> ". strtolower(translate('set')) ." ". strtolower(translate('and')) ." <b>". $total_reps ."</b> ". strtolower(translate('reps')) .". <br />" . ucf(translate('averageprliftwas')) . " <b>" . $average_lift . "" . $w_metric . ".</b><br />\n";
						echo post_stat_image($temp_list);
						echo"
						</div>\n";

for($i = $col_counter; $i < 3; $i++)
{
	echo "</td>";
}

?>
		</td>
		</tr>
	</table>
    
<div align="left" style="padding-top:9px; padding-left:500px;">
<b><u><?php echo ucf(translate('statisticovertraining')); ?></u></b><br />
			
            <?php 
			if($BLOG['meet'] == 0)
			{ 
			?>
                       
			<?php 
			echo translate('lifted') . " <b>" . $total_lifted . "" . $w_metric . "</b> " . translate('totally') . " ". translate('distributed') ."
			" . translate('on') .  " <b>" . $total2_set . "</b> " . translate('set') . " " . translate('and') . " <b>" . $total2_reps . "</b> " . translate('reps') . ".			
			<br />" . ucf(translate('averageprliftwas')) . " <b>" . $average_lift2 . "" . $w_metric . "</b>";
			?>
            
            <?php 
			}
			// Powerlifting meet
			elseif($BLOG['meet'] == 1)
			{
				echo ucf(translate('class')) . " ";
				// Check year for weightclass display, regarding changes to 2011 rules
				if($BLOG['date'] > mktime(0, 0, 0, 1, 1, 2011))
				{
					echo weightcat($BLOG['bodyweight'], $U_PROFILE->getGender());
				}
				else
				{
					echo weightCatOld($BLOG['bodyweight'], $U_PROFILE->getGender(), $U_PROFILE);
				}
				echo " " . translate(getCat($U_PROFILE->getBirthday(),$U_PROFILE->getGender()));
				echo "<br />";
				
				// Check if only bench press meet
				if(bestsquat($_REQUEST['tid']) == 0 && bestdeadlift($_REQUEST['tid']) == 0)
				{
					$totallifted = bestsquat($_REQUEST['tid'])+bestbench($_REQUEST['tid'])+bestdeadlift($_REQUEST['tid']);
					echo translate('lifted') . " <b>" . r_nr2(calcFromKg(bestbench($_REQUEST['tid']))) . $w_metric . "</b> - " . "<b>" . wilks($BLOG['bodyweight'], $U_PROFILE->getGender(), $totallifted) . "</b> " . strtolower(translate('wilkspoint'));
				}
				else
				{
					echo translate('lifted_serie') . " <b>" . r_nr2(calcFromKg(bestsquat($_REQUEST['tid']))) . "</b>-<b>" . r_nr2(calcFromKg(bestbench($_REQUEST['tid']))) . "</b>-<b>" . r_nr2(calcFromKg(bestdeadlift($_REQUEST['tid']))) . "</b>";
					echo "<br />";
					$totallifted = bestsquat($_REQUEST['tid'])+bestbench($_REQUEST['tid'])+bestdeadlift($_REQUEST['tid']);
					echo "<b>" . r_nr2(calcFromKg($totallifted)) . "" . $w_metric . "</b> " . translate('totally'). " " . translate('and') . " ";
					echo "<b>" . wilks($BLOG['bodyweight'], $U_PROFILE->getGender(), $totallifted) . "</b> " . strtolower(translate('wilkspoint'));
				}
			}
			// Weightlifting meet
			elseif($BLOG['meet'] == 3)
			{
				echo ucf(translate('class')) . " ";
				// Show weighclass & age class
				echo weightcatw($BLOG['bodyweight'], $U_PROFILE->getGender());
				echo " " . translate(getCatw($U_PROFILE->getBirthday(),$U_PROFILE->getGender()));
				echo "<br />";
				
				// Check if only bench press meet
					echo translate('lifted_serie') . " <b>" . r_nr2(calcFromKg(bestsnatch($_REQUEST['tid']))) . "</b>-<b>" . r_nr2(calcFromKg(bestcleanandjerk($_REQUEST['tid']))) . "</b>";
					echo "<br />";
					$totallifted = bestsnatch($_REQUEST['tid'])+bestcleanandjerk($_REQUEST['tid']);
					echo "<b>" . r_nr2(calcFromKg($totallifted)) . "" . $w_metric . "</b> " . translate('totally'). " " . translate('and') . " ";
					echo "<b>" . sinclair($BLOG['bodyweight'], $U_PROFILE->getGender(), $totallifted) . "</b> " . strtolower(translate('sinclairpoint'));
			}
			?>
            
            <br />
             <a href="index.php?action=profile&amp;sub=stats&amp;id=<?php echo $U_PROFILE->getId(); ?>" title="<?php echo translate('showmorestats'); ?>"><div style='float: left; clear: right; padding-right: 5px;'><img src='img/graf_bar.png' /></div><?php echo translate('showmorestats'); ?></a>
<br /><br />

			<?php
			if($BLOG['meet'] == 0)
			{
				// Hour to decimal
				$hoursDecimal = $BLOG['hours'];
				// Minute to decimal
				$minuteDecimal = $BLOG['minutes']/60;
				// Time to decimal			
				$timeToDecimal = $hoursDecimal+$minuteDecimal;
				// Reps pr.hour
				$repsPrHour = $total2_reps/$timeToDecimal; 
				// Set pr.hour
				$setPrHour = $total2_set/$timeToDecimal;
				
				// Pause pr.min
				
				echo "<b><u>". ucf(translate('effectiveness')) . "</u></b>
				<br />
				<b>" . round($setPrHour, 2) . "</b> " . translate('setprhour') . ".
				<br />
				<b>" . round($repsPrHour, 2) . "</b> " . translate('repsprhour') . ".
				<br /><br />";
			}
			?>
    
            <b><u><?php echo ucf(translate('factsaboutthistraining')); ?></u></b>
            <?php
			if($BLOG['hours'] > 0 || $BLOG['minutes'] > 0)
			{
			echo "<br /><div style='float: left; clear: right; padding-right: 5px;'><img src='img/clock.png' alt='" . ucf(translate('timespent')) . "' /></div>";
			}
			
			if($BLOG['hours'] > 0)
			{
				echo $BLOG['hours'] . " ";
			}
			
			if($BLOG['hours'] == 1)
			{ 
			 echo strtolower(translate('hour'));
			}
			
			if($BLOG['hours'] > 1)
			{
			 echo strtolower(translate('hours'));
			}
			
			if($BLOG['minutes'] == 0)
			{
				echo "";
			}
			
			if($BLOG['minutes'] > 0 && $BLOG['hours'] > 0)
			{
				echo " " .strtolower(translate('and'));
			}
			
			if($BLOG['minutes'] >= 1)
			{
				
				echo " ". $BLOG['minutes'] . " " . strtolower(translate('minutes')) . ""; 
			}
			?>
           
		<?php //hungdd ?>	
			<?php if(who_am_i()== 'ADMIN' || who_am_i() == 'MOD') : ?>
				<br/>
				<div style='float: left; clear: right; padding-right: 5px;'><img src='img/house.png' alt="<?php echo ucf(translate('place')); ?>" /></div><a href="index.php?action=gym&sub=view&gym_id=<?php echo $BLOG['gym_id'];?>"><?php echo $BLOG['place']; ?></a>
            <?php else: ?>
				<?php if(gym_status($BLOG['gym_id']) == 'ACTIVE'): ?>
					<br/>
					<div style='float: left; clear: right; padding-right: 5px;'><img src='img/house.png' alt="<?php echo ucf(translate('place')); ?>" /></div><a href="index.php?action=gym&sub=view&gym_id=<?php echo $BLOG['gym_id'];?>"><?php echo $BLOG['place']; ?></a>
				<?php endif; ?>
			<?php endif; ?>	
			
			<?php
            if($BLOG['category'] != "")
			{
				?>
				<br /><a href="index.php?action=profile&amp;id=<?php echo $U_PROFILE->getId(); ?>&amp;cat=<?php echo $BLOG['category']; ?>" title="<?php echo translate('showcatunder') . " " . $BLOG['category']; ?>"><div style='float: left; clear: right; padding-right: 5px;'><img src='img/folder.png' alt='<?php echo ucf(translate('category')); ?>' /></div> 
				<?php  
				if($BLOG['category'] == 'uncategorized')
				{
					echo translate($BLOG['category']);
				}
				else
				{
					echo $BLOG['category'];
				}
				?>
				</a>
				<?php
            }
            ?>
            
            <?php 
			if($U_PROFILE->getShowBw() == 1)
			{
			echo "<br /><div style='float: left; clear: right; padding-right: 5px;'><img src='img/male.png' alt='". ucf(translate('bodyweight')) . "' /></div> " .r_nr2(calcFromKg($BLOG['bodyweight'])) . "" . $w_metric . "";
			}
			?>
            <?php
			echo "<br /><div style='float: left; clear: right; padding-right: 5px;'><img src='img/group.png' alt='" . ucf(translate('nrvisitors')) ."' /></div> " . $viewer_total_numrows . " "; if($viewer_total_numrows == 1) { echo translate('oneview'); } else { echo translate('views'); }
			?>
<br />
            <?php
			if($newer_training != "")
			{
			?>
            <br />
            <a href="index.php?action=profile&amp;sub=show&amp;tid=<?php echo $newer_training; ?>" title="<?php echo ucf(translate('show')) . " " . strtolower(translate('newertraining')); ?>"><div style='float: left; clear: right; padding-right: 5px;'><img src='img/arrow_right (2).png' alt='<?php echo translate('newertraining'); ?>' /></div> <?php echo translate('newertraining'); ?></a>
            <?php 
			}
			?>
            <?php
			if($older_training != "")
			{
			?>
<br />
            <a href="index.php?action=profile&amp;sub=show&amp;tid=<?php echo $older_training; ?>" title="<?php echo ucf(translate('show')) . " " . strtolower(translate('oldertraining')); ?>"><div style='float: left; clear: right; padding-right: 5px;'><img src='img/arrow_left.png' alt='<?php echo translate('oldertraining'); ?>' /></div> <?php echo translate('oldertraining'); ?></a>
            <?php 
			}
			?>  
</div>
<div style="clear:both;"></div>
<?php 
} 
if($BLOG['meet'] == 2)
{
	echo "<br />";
}
echo $BLOG['comment'];
?>
<?php
if($BLOG['meet'] == 2)
{
			if($newer_training != "")
			{
			?>
            <a href="index.php?action=profile&amp;sub=show&amp;tid=<?php echo $newer_training; ?>" title="<?php echo ucf(translate('show')) . " " . strtolower(translate('newertraining')); ?>">
            <div style='float: left; clear: right; padding-right: 5px;'><img src='img/arrow_right (2).png' alt='<?php echo translate('newertraining'); ?>' /></div> <?php echo translate('newertraining'); ?></a>
            <?php 
			}
			if($older_training != "")
			{
			?>
			<br />
            <a href="index.php?action=profile&amp;sub=show&amp;tid=<?php echo $older_training; ?>" title="<?php echo ucf(translate('show')) . " " . strtolower(translate('oldertraining')); ?>">
            <div style='float: left; clear: right; padding-right: 5px;'><img src='img/arrow_left.png' alt='<?php echo translate('oldertraining'); ?>' /></div> <?php echo translate('oldertraining'); ?></a>
            <?php 
			}
}
?>
 
		</div>
		<div class="fixed"></div>
	</div>
<!-- Show single blog post END-->
<?php
if(checkSession() && ($USER->getId() == $BLOG['user_id']))
{
	$but_text = translate('disable_commenting');
	if($BLOG['disable_comment'] == 1)
	{
		$but_text = translate('enable_commenting');
	}
	?>
	<form method="post" action="<?php echo $url_to_post; ?>">
		<input style="font-weight:bold;" type="submit" name="toggle_commenting" value="<?php echo $but_text; ?>" />
	</form>	
	<?php
}

$total_rating_text = "";
$total_rating = 0;
$raters_count = 0;
foreach($comments as $k => $v)
{
	if($v['rating'] >= 0)
	{
		$total_rating += $v['rating'];
		$raters_count++;
	}
}

if($raters_count > 0)
{
	$rating_score = ($total_rating / $raters_count);
	$rating_score = round($rating_score, 1);
	
	$total_rating_text = translate('rating_score');
	$total_rating_text = str_replace('VAR1', $rating_score, $total_rating_text);
}

?>
<!-- comments START -->
<div id="comments">
		<div id="cmtswitcher">
			<a id="commenttab" class="curtab" href="javascript:void(0);" >
			<?php
			if(count($comments) == 0)
			{
			?>
			<?php echo ucf($comments_text0); ?>
			<?php
			}
			?>
			 <?php
			if(count($comments) == 1)
			{
			?>
			<?php echo $comments_text1; ?>
			<?php
			}
			?>
			<?php
			if(count($comments) >= 2)
			{
			?>
			<?php echo $comments_text2; ?>
			<?php
			}
			?>
            <?php
            if($total_rating_text != "")
			{
			?>
			<?php echo ", " . $total_rating_text; ?>
            <?php } ?></a>
            
            
            <span class="addcomment"><a href="#respond"><?php echo translate('write_comment'); ?></a></span>
			<div class="fixed"></div>
		</div>
		<div id="commentlist">
		<ol id="thecomments">   
<?php
$counter = count($comments) + 1;
$counter2 = 0;
$showing = 0;

foreach($comments as $key => $val)
{
	if($counter2 >= $start && $counter2 < $end)
	{
    $COMMENT = $val;
    $counter--;
    include('comments.php');
	$showing++;
	}
	$counter2++;
}
?>
<?php 
if($counter2 == 0)
{
?>
<li class="messagebox"><?php echo translate('no_comments_yet');?></li>
<?php
}
?>
        	</ol>
   		</div>
	</div>
<!-- comments END -->

</div>
<?php
if($BLOG['disable_comment'] != 1)
{
	$post_id = $BLOG['id'];
	$post_type = 'training';
	$post_url = $url_to_post;
	include('comments_new.php');

	}
	else
	{
		echo "<br /><br />".
		"<h3>" . translate('commenting_disabled') . "</h3>";
	}

}
else
{
?>
<!-- Show all blog post START-->
<div class="post">
	<h2><a class="title" href="<?php echo $url_to_post; ?>" rel="bookmark"><?php echo $BLOG['title']; ?></a></h2>
	<div class="info">
    
		<span class="date"><?php echo formatDate($BLOG['date'], ''); ?></span>
        
		<span class="author"><a href="index.php?action=profile&amp;id=<?php echo $U_PROFILE->getId(); ?>" title="<?php echo translate('postby'); ?> <?php echo $U_PROFILE->getFirstname() . " " . ucf($U_PROFILE->getLastname()); ?>"><?php echo $U_PROFILE->getFirstname() . " " . ucf($U_PROFILE->getLastname()); ?></a> (<?php echo r_nr(calcFromKg($BLOG['bodyweight'])) . "" . $w_metric; ?>)</span>
<?php
if(isset($USER) && $USER->getId() == $U_PROFILE->getId() or $USER->getRank() > 5)
{
	?>
				<!-- Only for admins and blog owner-->
        <span class="editpost"><a href="#" title="<?php echo translate('editp_sub'); ?>"><?php echo translate('editp'); ?></a></span>
	<?php
}
?>
		<span class="comments"><a href="<?php echo $url_to_post; ?>#comments" title="<?php echo $BLOG['title']; ?>"><?php echo $comments_text; ?></a></span>
        
<div class="fixed"></div>		
		<div class="fixed"></div>
	</div>
</div>
<!-- Show all blog post END-->
<?php
}
?>
<!-- Display pagenumber START -->
    
    	<?php
    	$post_text = $LANG['showing_comment'];
    	$post_text = str_replace('VAR1', $showing, $post_text);
    	$post_text = str_replace('VAR2', count($comments), $post_text);
    	
      if(count($comments) >  $USER->getCommentsPerPage())
      {
		echo "<center>" . $post_text . "<br />";
        displayPaging(count($comments), $USER->getCommentsPerPage(), $url_to_post, 'p', '<b>[', ']</b>'); 
		echo "</center>";
     	}
      ?>
    
    <!-- Display pagenumber END -->
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>
<?php
} // restrict view END
?>